#!/bin/bash

#set -o pipefail
set -o errexit
export LC_ALL=C

source 6_annotation/annotate_common.sh

BASE_DATA_PATH=/home/mixagol/data/
NORM_MATRIX_DIR=${BASE_DATA_PATH}/3_normed_matrix_wunw
GENOMES_NUM=`cat "${NORM_MATRIX_DIR}/map_int_genom.txt" | wc -l`

ANNOTATE_DIR=$1
EXCL_GENOMES=$(head -n1 ${ANNOTATE_DIR}/../excl_genomes.txt)

P_LIMIT="1e-5"

for Z_VALUE in 10; do
    E_DIR_BASE=$ANNOTATE_DIR/e_${Z_VALUE}
    E_DIR=$ANNOTATE_DIR/e_${Z_VALUE}_p${P_LIMIT}
    mkdir -p $E_DIR

    #create_vectors_nw      $ANNOTATE_DIR    $E_DIR    $Z_VALUE    $NORM_MATRIX_DIR   $EXCL_GENOMES
    #find_sim_vectors_raw                    $E_DIR    $Z_VALUE    $NORM_MATRIX_DIR   $GENOMES_NUM
    #find_sim_vectors                        $E_DIR    $Z_VALUE    $NORM_MATRIX_DIR
    cp ${E_DIR_BASE}/joined.txt.gz ${E_DIR}/joined.txt.gz
    create_kegg_limited                     $E_DIR    $Z_VALUE    ${P_LIMIT}
    create_gene_functions                   $E_DIR    $Z_VALUE
    create_gene_functions_kegg              $E_DIR    $Z_VALUE
    create_gene_functions_uniq              $E_DIR    $Z_VALUE
    create_gene_functions_best_uniq         $E_DIR    $Z_VALUE
    create_gene_functions_best_uniq_kegg    $E_DIR    $Z_VALUE
    create_gene_pathways                    $E_DIR    $Z_VALUE
    #create_gene_pathways_avg_nw             $E_DIR    $Z_VALUE    $GENOMES_NUM

done

